<?php

class NewsController extends FController {

    public function actionInfo($page = '') {
        $model = new FNews();
        $data  = $model->getDetail($page);

        if ($data) {
            $this->render('info', array(
                'model' => $model,
                'data' => $data,
            ));
        } else {
            throw new CHttpException('403', Yii::t('msg', 'page_not_found'));
        }
    }
    
    public function actionDetail($page = '') {
        $model = new FNews();
        $data  = $model->getDetail($page);

        if ($data) {
            $this->render('detail', array(
                'model' => $model,
                'data' => $data,
            ));
        } else {
            throw new CHttpException('403', Yii::t('msg', 'page_not_found'));
        }
    }
    
    public function actionCat($var='') {
        if (! empty($var)) {
            $model = new FNews();
            $typeInfo = $model->getType($var);
            $data = $model->getCategory($typeInfo['type_id']);

            if ( $typeInfo && $data ) {
                $this->render('category', array(
                    'model'     => $model,
                    'data'      => $data,
                    'typeInfo' => $typeInfo,
                ));
            } else {
                throw new CHttpException('403', Yii::t('msg', 'page_not_found'));
            }
        } else {
            throw new CHttpException('403', Yii::t('msg', 'page_not_found'));
        }
    }

}